import request from '@/utils/request'

export function list(form) {
  return request({
    url: 'api/docker/container/list',
    method: 'post',
    data: {
        server_id:form.server_id,
        container_id: form.container_id,
        container_name: form.container_name
    }
  })
}

export function start(data) {
  return request({
    url: 'api/docker/container/start',
    method: 'post',
    data: data
  })
}

export function stop(data) {
  return request({
    url: 'api/docker/container/stop',
    method: 'post',
    data: data
  })
}

export function restart(data) {
  return request({
    url: 'api/docker/container/restart',
    method: 'post',
    data: data
  })
}

export function images(server_id) {
  return request({
    url: 'api/docker/image/list',
    method: 'post',
    data: {
        server_id:server_id
    }
  })
}

export function save(form) {
  return request({
    url: 'api/docker/container/save',
    method: 'post',
    data: {
      server_id:form.server_id,
      container_name:form.container_name,
      image_name:form.image_name,
      bind_port:form.bind_port,
      net_work:form.net_work,
      always_restart:form.always_restart,
      tty:form.tty,
      cmd:form.cmd,
      ip4_address:form.ip4_address,
      ip6_address:form.ip6_address,
      working_dir:form.working_dir,
      mount_path:form.mount_path,
      env:form.env,
      note:form.note
    }
  })
}

export function remove(server_id,container_id,container_name) {
  return request({
    url: 'api/docker/container/remove',
    method: 'post',
    data: {
        server_id:server_id,
        container_id:container_id,
        container_name:container_name
    }
  })
}

export function cmd(server_id,container_name) {
  return request({
    url: 'api/docker/container/cmd',
    method: 'post',
    data: {
        server_id:server_id,
        container_name:container_name
    }
  })
}

export function detail(cr_id) {
  return request({
    url: 'api/docker/container/detail',
    method: 'post',
    data: {
      cr_id:cr_id
    }
  })
}

export function look() {
  return request({
    url: 'api/docker/container/look',
    method: 'post',
    data: {}
  })
}